package xdman.ui.laf;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.metal.MetalLookAndFeel;

import static xdman.util.XDMUtils.getScaledInt;

public class XDMLookAndFeel extends MetalLookAndFeel {

    private static final long serialVersionUID = 6437510613485554397L;

    public XDMLookAndFeel() {
        setCurrentTheme(new XDMTheme());
    }

    @Override
    public void initClassDefaults(UIDefaults table) {
        super.initClassDefaults(table);
        table.putDefaults(new Object[]{"ButtonUI", XDMButtonUI.class.getName(), "TextFieldUI",
                XDMTextFieldUI.class.getName(), "TextAreaUI", XDMTextAreaUI.class.getName(), "SliderUI",
                XDMSliderUI.class.getName(), "LabelUI", XDMLabelUI.class.getName(), "ScrollBarUI",
                XDMScrollBarUI.class.getName(), "MenuItemUI", XDMMenuItemUI.class.getName(), "MenuUI",
                XDMMenuUI.class.getName(), "CheckBoxMenuItemUI", XDMMenuItemUI.class.getName(), //"TreeUI",
                //XDMTreeUI.class.getName(),
                "SpinnerUI", XDMSpinnerUI.class.getName(), "ProgressBarUI",
                XDMProgressBarUI.class.getName(), "ComboBoxUI", XDMComboBoxUI.class.getName()});
        System.setProperty("xdm.defaulttheme", "true");

        UIManager.put("Table.focusCellHighlightBorder", new EmptyBorder(1, 1, 1, 1));
        UIManager.put("ComboBox.rendererUseListColors", Boolean.TRUE);
        UIManager.put("Slider.thumbWidth", getScaledInt(4));
    }

    protected void initComponentDefaults(UIDefaults table) {
        super.initComponentDefaults(table);
    }

    public String getName() {
        return "Default";
    }

    public String getID() {
        return "Default";
    }

    @Override
    public String getDescription() {
        return "Default theme for XDM";
    }

    @Override
    public boolean isNativeLookAndFeel() {
        return false;
    }

    @Override
    public boolean isSupportedLookAndFeel() {
        return true;
    }
}
